#!/usr/bin/python3
# -*- encoding: utf-8 -*-
'''
@File        :爬取免费代理.py
@Time        :2020/08/25 14:25:12
@Author      :hejiang
@Software    :vsCode
'''
import Requestdef


def IPList_61():
    for q in [1, 2]:
        url = 'http://www.66ip.cn/' + str(q) + '.html'
        html = Requestdef.get_page(url)
        if html != None:
            #print(html)
            iplist = BeautifulSoup(html, 'lxml')
            iplist = iplist.find_all('tr')
            i = 2
            for ip in iplist:
                if i <= 0:
                    loader = ''
                    # print(ip)
                    j = 0
                    for ipport in ip.find_all('td', limit=2):
                        if j == 0:
                            loader += ipport.text.strip() + ':'
                        else:
                            loader += ipport.text.strip()
                        j = j + 1
                    Requestdef.inspect_ip(loader)
                i = i - 1
        time.sleep(1)


IPList_61()